package org.graduation.model.dtos.RBAC;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.graduation.model.common.RBAC.Permissions;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class CheckPermissionsDTO extends PermissionsInfoDTO {
    protected Permissions permissions;
    protected Integer permissionsId;

    public CheckPermissionsDTO(Long pId, Integer uid, Permissions permissions) {
        super(pId, uid);
        this.permissions = permissions;
    }

    public CheckPermissionsDTO(Long pId, Integer uid, Integer permissionsId) {
        super(pId, uid);
        this.permissions = Permissions.valueOf(permissionsId);
    }

    public Permissions getPermissions() {
        if (this.permissions == null) {
            return Permissions.valueOf(permissionsId);
        } else {
            return this.permissions;
        }
    }
}
